/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hudson.msservice.timeremail;

import hudson.msservice.Messages;


/**
 *
 * @author janksenhu
 */
public class MessageUtil {

    /**
     * return chinese of SUCCESS,ABORT,FAILTRUE
     */
    public static String getChineseOfResult(String result) {
       
       if (result!=null && result.equals("SUCCESS")) {
            return Messages.Result_SUCCESS();
        } else if (result!=null && result.equals("FAILURE")) {
            return Messages.Result_FAILURE();
        } else if (result!=null && result.equals("ABORTED")) {
            return Messages.Result_ABORTED();
        } else if (result!=null && result.equals("not_execute_steps")){
            return Messages.Result_NotSchedule();
        } else {
            return Messages.Result_NoResult();
        }
        
    }
    
    /**
     * build duration to a string like 32mins 
     * 
     */
    public static String getTimeStringOfDuration(int duration){
        String format=String.format("%.2f",duration/(1000*60.0));
        return format+Messages.Time_Minute();
    }
    
    
    /**
     * we filter some user like  
     *  timer,SYSTEM,test #102,anonymous
     */
    public static boolean isTencentDomainUser(String username){
        String [] tem={"timer","SYSTEM","anonymous"};
        for(String str:tem){            
            if(username.equals(str)){
                return false;
            }else if(username.indexOf("#")>-1){
                return false;
            }
        }
        return true;
    }
}
